package com.ljkj.cordial.chat.widget;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.ljkj.cordial.chat.R;
import com.nic.view.widget.CommonPopupWindow;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class MainMenuPop extends CommonPopupWindow {
    @BindView(R.id.ll_create_group)
    LinearLayout llCreateGroup;
    @BindView(R.id.ll_add_friend)
    LinearLayout llAddFriend;

    public MainMenuPop(Context c) {
        super(c, R.layout.dialog_main_menu, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        Unbinder unbind = ButterKnife.bind(this, contentView);
//        getPopupWindow().setOnDismissListener(new PopupWindow.OnDismissListener() {
//            @Override
//            public void onDismiss() {
//                unbind.unbind();
//            }
//        });
        llCreateGroup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getPopupWindow().dismiss();
                if (onCreateGroupListener != null) {
                    onCreateGroupListener.onClick(v);
                }
            }
        });
        llAddFriend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getPopupWindow().dismiss();
                if (onAddFriendListener != null) {
                    onAddFriendListener.onClick(v);
                }
            }
        });
        getPopupWindow().setOutsideTouchable(true);
    }

    public void setOnCreateGroupListener(OnCreateGroupListener onCreateGroupListener) {
        this.onCreateGroupListener = onCreateGroupListener;
    }

    public void setOnAddFriendListener(OnAddFriendListener onAddFriendListener) {
        this.onAddFriendListener = onAddFriendListener;
    }

    private OnCreateGroupListener onCreateGroupListener;
    private OnAddFriendListener onAddFriendListener;

    public interface OnCreateGroupListener {
        void onClick(View v);
    }

    public interface OnAddFriendListener {
        void onClick(View v);
    }
}
